<?php

class BaseAction extends Action{
protected $lang_pack;
public function __construct()
{
parent::__construct();
check_install();
$langSet = conf('DEFAULT_LANG');
define('LANG_SET',strtolower($langSet));
if (is_file(LANG_PATH.$langSet.'/common.php'))
{
L(include LANG_PATH.$langSet.'/common.php');
$this->lang_pack = require LANG_PATH.$langSet.'/common.php';
if(!file_exists(APP_ROOT_PATH.'public/runtime/admin/lang.js'))
{
$str = 'var LANG = {';
foreach($this->lang_pack as $k=>$lang)
{
$str .= "\"".$k."\":\"".$lang."\",";
}
$str = substr($str,0,-1);
$str .='};';
file_put_contents(APP_ROOT_PATH.'public/runtime/admin/lang.js',$str);
}
}
}
protected function error($message,$ajax = 0)
{
if(!$this->get('jumpUrl'))
{
if($_SERVER['HTTP_REFERER']) $default_jump = $_SERVER['HTTP_REFERER'];else $default_jump = u('Index/main');
$this->assign('jumpUrl',$default_jump);
}
parent::error($message,$ajax);
}
protected function success($message,$ajax = 0)
{
if(!$this->get('jumpUrl'))
{
if($_SERVER['HTTP_REFERER']) $default_jump = $_SERVER['HTTP_REFERER'];else $default_jump = u('Index/main');
$this->assign('jumpUrl',$default_jump);
}
parent::success($message,$ajax);
}
}
?>